package com.example.micro_property_springboot.service.impl;

import com.example.micro_property_springboot.pojo.AssetInfo;
import com.example.micro_property_springboot.mapper.AssetStatisticsMapper;
import com.example.micro_property_springboot.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 统计分析服务实现类
 * 实现资产统计分析的业务逻辑
 */
@Service
public class StatisticsServiceImpl implements StatisticsService {

    @Autowired
    private AssetStatisticsMapper statisticsMapper;

    /**
     * 获取资产概览统计数据
     */
    @Override
    public Object getAssetOverview() {
        Map<String, Object> overview = new HashMap<>();
        // 获取总资产数量
        overview.put("totalCount", statisticsMapper.getTotalAssetCount());
        // 获取总资产价值
        overview.put("totalValue", statisticsMapper.getTotalAssetValue());
        // 获取近30天新增资产数量
        overview.put("newAssetsCount", statisticsMapper.getNewAssetsCount(30));
        // 获取近30天报废资产数量
        overview.put("scrapAssetsCount", statisticsMapper.getScrapAssetsCount(30));
        return overview;
    }

    /**
     * 获取资产状态分布统计
     */
    @Override
    public List<Object> getAssetStatusDistribution() {
        return statisticsMapper.getAssetStatusDistribution();
    }

    /**
     * 获取部门资产分布统计
     */
    @Override
    public List<Object> getAssetDeptDistribution() {
        return statisticsMapper.getAssetDeptDistribution();
    }

    /**
     * 获取资产分类分布统计
     */
    @Override
    public List<Object> getAssetCategoryDistribution() {
        return statisticsMapper.getAssetCategoryDistribution();
    }

    /**
     * 获取资产价值趋势数据
     */
    @Override
    public List<Object> getAssetValueTrend(String startDate, String endDate) {
        return statisticsMapper.getAssetValueTrend(startDate, endDate);
    }

    /**
     * 获取资产台账列表
     */
    @Override
    public List<AssetInfo> getAssetLedgerList() {
        return statisticsMapper.getAssetLedgerList();
    }

    /**
     * 获取资产流转报表数据
     */
    @Override
    public List<Map<String, Object>> getAssetTransferReport() {
        return statisticsMapper.getAssetTransferReport();
    }

    /**
     * 获取部门领用热度数据
     */
    @Override
    public List<Map<String, Object>> getDeptUsageHotness() {
        return statisticsMapper.getDeptUsageHotness();
    }
}